package com.study.design.model.structPattern.flyWeight;

import org.junit.Test;

/**
* @Name: Client
* @Description: 享元模式测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-2-15 下午2:47:53 
* @Version: V1.0
 */
public class Client {
	
	@Test
	public void flyWeight() {
		//创建享元对象，并设置内部状态
		ChessFlyWeight chess01 = ChessFlyWeightFactory.getChess("黑色") ;
		ChessFlyWeight chess02 = ChessFlyWeightFactory.getChess("黑色") ;
		//相同内部状态的享元对象为相同对象
		System.out.println(chess01);
		System.out.println(chess02);
		//设置外部状态
		chess01.display(new Coordinate(10, 10)) ;
		chess02.display(new Coordinate(20, 20)) ;
	}

}
